module.exports = {
  success(data) {
    this.ctx.body = data;
    this.ctx.status = 200;
  },

  notFound(err) {
    this.ctx.body = err;
    this.ctx.status = 404;
  },

  error(err) {
    this.ctx.body = err;
    this.ctx.status = 500;
  },

  /**
   * 输出文件
   * @param name
   * @param stream
   */
  file({name, stream}) {
    name = encodeURI(name);
    this.ctx.set('Content-disposition', 'attachment; filename="' + name + '"');
    this.ctx.body = stream;
  },
};
